Skip to content

Revert "fix(workspace url id bug): switch workspace bug "#567

Merged
icecrasher321 merged 1 commit intostagingfrom
revert-564-fix/switch-workspace-url-bug
Jun 27, 2025
Merged

Revert "fix(workspace url id bug): switch workspace bug "#567
icecrasher321 merged 1 commit intostagingfrom
revert-564-fix/switch-workspace-url-bug

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Reverts #564

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2025 9:07pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jun 27, 2025 9:07pm

@delve-auditor
Copy link
Copy Markdown

delve-auditor Bot commented Jun 27, 2025

No security or compliance issues detected. Reviewed everything up to 597f770.

Security Overview
  • 🔎 Scanned files: 6 changed file(s)
Detected Code Changes
Change Type Relevant files
Revert ► route.ts
    Remove sorting by createdAt in workflow queries
► workspace-header.tsx
    Simplify workspace switching logic
► sidebar.tsx
    Add client-side sorting for workflows
► page.tsx
    Remove workspace-specific workflow loading
► socket-context.tsx
    Add workflow state logging
► store.ts
    Remove sorting comment

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR reverts significant workspace switching and workflow ordering changes from PR #564, potentially reintroducing several critical issues.

  • Removed crucial database sorting by lastModified desc in apps/sim/stores/workflows/registry/store.ts, impacting workflow display consistency
  • Reverted workspace transition handling in apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx, which may reintroduce race conditions during switching
  • Simplified but potentially problematic workspace ID handling in apps/sim/app/workspace/[workspaceId]/w/page.tsx, removing safeguards against duplicate loading
  • Removed optimistic UI updates and error handling in workspace-header.tsx, making workspace switching less resilient
  • Eliminated workflow sorting by creation date in apps/sim/app/api/workflows/sync/route.ts, affecting ordered workflow display

6 files reviewed, 3 comments
Edit PR Review Bot Settings | Greptile

Comment on lines 466 to 472
// If deleted workspace was active, switch to another workspace
if (activeWorkspace?.id === id && updatedWorkspaces.length > 0) {
const newWorkspace = updatedWorkspaces[0]
setActiveWorkspace(newWorkspace)

// Use the specialized method for handling workspace deletion with explicit workspace ID
useWorkflowRegistry.getState().handleWorkspaceDeletion(newWorkspace.id)

// Update URL to the new workspace
router.push(`/workspace/${newWorkspace.id}/w`)
// Use the specialized method for handling workspace deletion
const newWorkspaceId = updatedWorkspaces[0].id
useWorkflowRegistry.getState().handleWorkspaceDeletion(newWorkspaceId)
setActiveWorkspace(updatedWorkspaces[0])
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Missing router.push after workspace deletion. User may remain on deleted workspace URL.

Suggested change
// If deleted workspace was active, switch to another workspace
if (activeWorkspace?.id === id && updatedWorkspaces.length > 0) {
const newWorkspace = updatedWorkspaces[0]
setActiveWorkspace(newWorkspace)
// Use the specialized method for handling workspace deletion with explicit workspace ID
useWorkflowRegistry.getState().handleWorkspaceDeletion(newWorkspace.id)
// Update URL to the new workspace
router.push(`/workspace/${newWorkspace.id}/w`)
// Use the specialized method for handling workspace deletion
const newWorkspaceId = updatedWorkspaces[0].id
useWorkflowRegistry.getState().handleWorkspaceDeletion(newWorkspaceId)
setActiveWorkspace(updatedWorkspaces[0])
}
// If deleted workspace was active, switch to another workspace
if (activeWorkspace?.id === id && updatedWorkspaces.length > 0) {
// Use the specialized method for handling workspace deletion
const newWorkspaceId = updatedWorkspaces[0].id
useWorkflowRegistry.getState().handleWorkspaceDeletion(newWorkspaceId)
setActiveWorkspace(updatedWorkspaces[0])
// Navigate to the new workspace
router.push(`/workspace/${newWorkspaceId}/w`)
}

.from(workflow)
.where(eq(workflow.workspaceId, workspaceId))
.orderBy(desc(workflow.createdAt))
workflows = await db.select().from(workflow).where(eq(workflow.workspaceId, workspaceId))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Missing orderBy clause - workflows are no longer sorted by creation date which could affect frontend display order

Comment on lines +21 to 24
// If we have workflows, redirect to the first one
if (workflowIds.length > 0) {
router.replace(`/workspace/${workspaceId}/w/${workflowIds[0]}`)
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: No verification that workflows belong to current workspace before redirect. Could cause incorrect routing

@icecrasher321 icecrasher321 merged commit e452396 into staging Jun 27, 2025
4 checks passed
@waleedlatif1 waleedlatif1 deleted the revert-564-fix/switch-workspace-url-bug branch June 28, 2025 04:46
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant